1) Field of the Invention
The present invention relates to a load-balancing device and a computer-readable recording medium in which a load-balancing program is recorded, where the load-balancing device and the load-balancing program distribute request messages to servers in such a manner that loads imposed on the servers are balanced, and request messages related to each other are assigned to an identical one of the servers for guaranteeing the uniqueness.
2) Description of the Related Art
Conventionally, the load-balancing technology is known as an essential element which is indispensable for constructing a reliable client-server system. FIG. 8 is a diagram illustrating an example of a configuration of a client-server system having a conventional load-balancing device.
In the client-server system of FIG. 8, a load-balancing device 910 is arranged between a server group 930 which performs processing for predetermined services and a client group (users' devices) 940 which sends request messages (which may be hereinafter referred to as “requests”) toward the server group 930 at arbitrary timings. For example, when a request directed to a virtual address representing the server group 930 is transmitted from a client A (941), the load-balancing device 910 receives the request, selects an optimum destination server from the server group 930, and transfers the request. That is, every time the load-balancing device 910 receives a request from a client, the load-balancing device 910 delivers the request to an optimum server. However, in some cases, requests for some types of services are required to be sent to an identical destination server. For example, in shopping sites, it is necessary that each client be connected to an identical server during a purchasing process for list management of an article to be purchased. For this purpose, the load-balancing device 910 has a session-maintaining function which delivers requests related to each other, to an identical server. The session-maintaining function is also called the uniqueness-guaranteeing function which guarantees the uniqueness of data between each client and each server. Hereinafter, the session-maintaining function is referred to as the uniqueness-guaranteeing function.
The uniqueness-guaranteeing function can be typically realized by techniques using: (1) an IP (Internet Protocol) address of a source of a message (source IP address); (2) a cookie which is set by a server; (3) a cookie which is set by a load-balancing device; or the like.
(1′) In the case where the uniqueness-guaranteeing function uses a source IP address, the client is identified by the source IP address, so that requests from an identical client can be delivered to an identical server.
(2′) In the case where the uniqueness-guaranteeing function uses a cookie which is set by a server, functions related to the cookie used between a server and a client are utilized. That is, when necessary, the server adds to a response message a cookie unique to a user before sending the response message to the client. At this time, the cookie is set so that the cookie is unlikely to overlap other cookies. For example, the cookie is a character string which is randomly set. The client has a function of adding the above cookie to a request and sending the request when the client is required to access the above server. The load-balancing device utilizes the above functions. That is, the load-balancing device memorizes cookies set by the servers. When a request to which a cookie is attached is sent from a client, the load-balancing device delivers the request to a server which issues the cookie, on the basis of the cookie attached to the request. Alternatively, it is possible to use embedded URL (Uniform Resource Locator) parameters instead of the cookies.
(3′) In the case where the uniqueness-guaranteeing function uses a cookie which is set by a load-balancing device, the load-balancing device generates a cookie. For example, when the load-balancing device delivers a request 951 from the client A (941), to the server a (931), the load-balancing device attaches a cookie c1 (953) to a response 952 from the server a (931), and returns the response 952 to the client A (941). Thereafter, when a request to which the cookie c1 (953) is attached is sent from the client A (941), the load-balancing device delivers the request to the server a (931) on the basis of the cookie c1 (953).
In addition, a relay device which employs a technique using a cookie function has been proposed, for example, in Japanese Unexamined Patent Publication No. 2004-178286 (Paragraph Nos. <0092> to <0113> and FIG. 2). When data containing a cookie is transmitted from a server, the above relay device overwrites a portion of the cookie contained in the transmitted data with a server identifier, and sends the data to the client. When data containing a cookie is transmitted from a client, the above relay device determines a destination on the basis of a server identifier included in the cookie which is contained in the data transmitted from the client.
However, in the conventional load-balancing processing, sometimes the uniqueness cannot be guaranteed according to the system configuration or the service type as indicated below.
(1″) In the case where the uniqueness-guaranteeing function uses a source IP address, usually each client has an identical IP address. However, in some cases where a proxy exists on the client side, the source IP address of an identical client can be dynamically changed. That is, in some cases, the uniqueness cannot be guaranteed even in a single service.
(2″) In the case where the uniqueness-guaranteeing function uses a cookie which is set by a server, servers independently set a cookie for each application corresponding to an individual service. Therefore, the uniqueness is guaranteed in each service. However, it is difficult to guarantee the uniqueness across multiple services. Thus, in order to guarantee the uniqueness, for example, it is necessary to perform processing for integrating the multiple services into a single service, or making multiple service applications cooperate with each other. Nevertheless, in order to perform such processing, it is necessary to develop a new application, so that a great amount of labor is required.
(3″) In the case where the uniqueness-guaranteeing function uses a cookie which is set by a load-balancing device, it is difficult to guarantee the uniqueness across multiple services as in the above case (2″).
FIG. 9 is a diagram illustrating processing for setting a cookie in a conventional load-balancing device. In the following explanations, it is assumed that the services A1 and A2 are related to each other, and are required to be handled by an identical server. When the client A (941) starts the service A1, and transmits toward the server a request for the service A1, the load-balancing system a (910) receives the request, and selects a destination server for the request. For example, when the load-balancing system a (910) delivers the request to the server a (931), the load-balancing system a (910) attaches a cookie c1 to a response to be returned to the client A (941), and sets the information indicating the service A1, the cookie c1, and the destination server “server a” in a management table 911, which is provided in the load-balancing system a (910). Thereafter, the cookie c1 is attached to each request from the client A (941) for the service A1. Therefore, the load-balancing system a (910) can deliver each request from the client A (941), to the server a (931) by referring to the management table 911. However, even if the client A (941) attaches the cookie c1 to a request for the service A2 after the service A2 is started, the load-balancing system a (910) newly determines a destination server, sets a cookie, and performs registration, since the settings for the service A2 are not made in the management table 911. In this case, there is a possibility that the request for the service A2 is delivered to a server other than the server a (931), e.g., the server b (932). Thus, the uniqueness is not guaranteed, and processing similar to the processing required to be performed in the case where the uniqueness-guaranteeing function uses a cookie set by a server is also required to be performed, and it is difficult to perform such processing.
Further, in the case where a plurality of load-balancing devices are provided, the uniqueness is not guaranteed either. For example, when the client A (941) attaches the cookie c1 to a request for the service A1 and transmits the request, and the load-balancing system a (910) receives the request, no problem occurs since the information indicating the service A1 and the cookie c1 are set in the management table 911. However, when the load-balancing system b (920) receives the above request, the load-balancing system b (920) independently determines a destination server, and sets a cookie, since the settings for the service A1 are not made in the management table 921. Therefore, the load-balancing system b (920) can deliver the above request to the server b (932), sets a cookie c3, and returns to the client A (941) a result to which the cookie c3 is attached, so that the uniqueness is not guaranteed. In this case, if only one load-balancing device is used, or a management table is shared by the plurality of load-balancing devices, the uniqueness is guaranteed. However, such countermeasures are not realistic.
Furthermore, similar problems to the above also occur in the case where the uniqueness-guaranteeing function uses a cookie which is set by a server, or the technique using a cookie as disclosed in Japanese Unexamined Patent Publication No. 2004-178286 is used.
As described above, according to the conventional load-balancing processing, it is difficult to guarantee the uniqueness when more than one load-balancing device exists, or when more than one service is required to be handled by an identical server.